"""
example08 - 字典中保存了股票信息，完成下面的操作
1、找出股票价格大于100元的股票并创建一个新的字典
2、找出价格最高和最低的股票对应的股票代码
3、按照股票价格从高到低给股票代码排序

Author: Administrator
Date: 2024/1/17
"""

stocks = {
    'AAPL': 191.88,
    'GOOG': 1186.96,
    'IBM': 149.24,
    'ORCL': 48.44,
    'ACN': 166.89,
    'FB': 208.09,
    'SYMC': 21.29
}

# new_stocks = {}
# for key, value in stocks.items():
#     if value > 100:
#         new_stocks[key] = value

new_stocks = {key: value for key, value in stocks.items() if value > 100}
print(new_stocks)

# _, max_code = max(zip(stocks.values(), stocks.keys()))[1]
# print(max_code)
# print(min(zip(stocks.values(), stocks.keys()))[1])
print(max(stocks, key=stocks.get))
print(min(stocks, key=stocks.get))

print(sorted(stocks, key=stocks.get, reverse=True))


# 键值转换
# dict1 = dict(zip(stocks.values(), stocks.keys()))
print()
